package com.zn.config;

import com.zn.vo.OptionSymbol;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author YinJiaWei
 * @version 2019/1/2 13:11
 * 本地缓存类
 */
@Component
public class NativeMemoryConfig {
    public static Map<String,OptionSymbol> OPTIONSYMBOLMAP=new HashMap<String,OptionSymbol>();
    /**数据格式 underwayKline|k线类型|FG809|2018-08-13 11:04:13|1466.000|1466.000|1467.000|1466.000|12724|0.00|53282.000|FG|09|**/
    /**一分钟线 1**/
    public static final ConcurrentHashMap<String, String> UNDERWAY_KLINE_ONE_MIN = new ConcurrentHashMap<>();
    /**五分线 2**/
    public static final ConcurrentHashMap<String, String> UNDERWAY_KLINE_FIVE_MIN = new ConcurrentHashMap<>();
    /**十五分线 3**/
    public static final ConcurrentHashMap<String, String> UNDERWAY_KLINE_FIFTEEN_MIN = new ConcurrentHashMap<>();
    /**三十分钟线 4**/
    public static final ConcurrentHashMap<String, String> UNDERWAY_KLINE_THIRTY_MIN = new ConcurrentHashMap<>();
    /**一小时线 5**/
    public static final ConcurrentHashMap<String, String> UNDERWAY_KLINE_ONE_HR = new ConcurrentHashMap<>();
    /**四小时线 6**/
    public static final ConcurrentHashMap<String, String> UNDERWAY_KLINE_FOUR_HR = new ConcurrentHashMap<>();
    /**日线 7**/
    public static final ConcurrentHashMap<String, String> UNDERWAY_KLINE_DAY = new ConcurrentHashMap<>();

    /**
     * 15：30将内存中的 optionSymbol清除
     */
    @Scheduled(cron="0 30 15 * * ?")
    private void clear(){
        OPTIONSYMBOLMAP.clear();
        UNDERWAY_KLINE_ONE_MIN.clear();
        UNDERWAY_KLINE_FIVE_MIN.clear();
        UNDERWAY_KLINE_FIFTEEN_MIN.clear();
        UNDERWAY_KLINE_THIRTY_MIN.clear();
        UNDERWAY_KLINE_ONE_HR.clear();
        UNDERWAY_KLINE_FOUR_HR.clear();
        UNDERWAY_KLINE_DAY.clear();
    }


}
